Skip to content

[fix] [sdf] Sdf text alpha double multiplication#2

Merged
chiefcll merged 1 commit into
solid-tv:mainfrom
CosmaVergari:fix/text-double-alpha
May 8, 2026
Merged

[fix] [sdf] Sdf text alpha double multiplication#2
chiefcll merged 1 commit into
solid-tv:mainfrom
CosmaVergari:fix/text-double-alpha

Conversation

@CosmaVergari
Copy link
Copy Markdown
Contributor

The text color was being premultiplied by alpha twice:

  • on CPU: RGB channels were multiplied by the normalized alpha value before being packed into the vertex buffer
  • on GPU: in the fragment shader v_color.rgb * opacity

This resulted in a double moltiplication of alpha channel, leading to wrong transparency results.

Solution: Removed the CPU-side premultiplication in addSdfQuads(). The color is now packed as straight (non-premultiplied) RGBA into the vertex attribute, and the SDF fragment shader remains the single point where premultiplied alpha blending is applied.

@chiefcll chiefcll merged commit ee7988f into solid-tv:main May 8, 2026
chiefcll added a commit that referenced this pull request May 11, 2026
Three changes covering the hot update path for x/y changes on simple
nodes (no rotation/scale/mount):

1. CoreNode.update Global block: when both the node is simple and the
   parent's global is translate-only, the resulting global is also
   translate-only and collapses to two adds on tx/ty — bypassing the
   6-field Matrix3d.copy + 2 mul-add translate. Tracked with a per-node
   _globalIsTranslate flag that propagates down the tree. RTT chains
   conservatively opt out.

2. updateLocalTransform simple path: localTransform is guaranteed to be
   identity-shape (ta=1, tb=0, tc=0, td=1), so only tx/ty need to change
   between frames. _localIsTranslate tracks whether the matrix is still
   in identity-shape so a non-simple -> simple transition correctly
   restores it.

3. updateBoundingRect: fix `||` -> `&&` on the axis-aligned-fast-path
   check. With `||`, a matrix with one zero shear component and the other
   non-zero (e.g. tb=0, tc=-0.5) wrongly took the diagonal fast path and
   produced incorrect bounds. Now matches calculateRenderCoords semantics.

Adds setTranslate() helper to Matrix3d for the in-place tx/ty + mutation
flag write used by both #1 and #2.

Adds 12 unit tests covering simple-path reuse, non-simple -> simple
transitions, translate-only propagation through grandchildren, fast-path
opt-out when parent has rotation, and the bounding-rect axis check.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants